﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Gao.Poker.App.Desktop;
using Gao.Poker.App.Game;
using Gao.Poker.App.Members;
using Gao.Poker.App.Sms;
using Gao.Poker.App.Store;
using Gao.Poker.App.Sys;
using Gao.Poker.App.View.Storage;
using Gao.Poker.Domain;
using MessageBox = Xceed.Wpf.Toolkit.MessageBox;

namespace Gao.Poker.App
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWin : Window
    {
        private User _user;

        public MainWin()
        {
            InitializeComponent();
            FullScreenManager.RepairWpfWindowFullScreenBehavior(this);
            Application.Current.MainWindow = this;
        }

        public User User
        {
            get { return _user; }
            set
            {
                _user = value;
                if(value != null)
                    tbUserName.Text = value.UserName;
            }
        }

        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.DragMove();
        }

        private void closeButton_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("你是否真要退出本系统", "提示信息", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
            {
                Application.Current.Shutdown();
                this.Close();
            }
            
        }

        private void maxButton_Click(object sender, RoutedEventArgs e)
        {
            if (WindowState == WindowState.Normal)
                WindowState = WindowState.Maximized;
            else
                WindowState = WindowState.Normal;
        }

        private void mniButton_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }

        private void menuButton_Click(object sender, RoutedEventArgs e)
        {
            Menu.IsOpen = true;
        }

        private void Member_Click(object sender, RoutedEventArgs e)
        {
            cc.Content = MemberMain.Instance();
        }

        private void Game_Click(object sender, RoutedEventArgs e)
        {
            cc.Content = GameMain.Instance();
        }

        private void Store_Click(object sender, RoutedEventArgs e)
        {
            cc.Content = StoneMain.Instance();
        }

        private void Table_Click(object sender, RoutedEventArgs e)
        {
            cc.Content = GameTables.Instance();
        }

        private void Sms_Click(object sender, RoutedEventArgs e)
        {
            cc.Content = SmsMain.Instance();
        }

        private void ModifyPWd_Click(object sender, RoutedEventArgs e)
        {
            ModifyPwd win = new ModifyPwd();
            win.User = User;
            win.Show();
        }

        /// <summary>
        /// 退出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Exit_Click(object sender, RoutedEventArgs e)
        {
            closeButton_Click(sender, e);
        }

        private void Storage_Click(object sender, RoutedEventArgs e)
        {
            cc.Content = StorageMain.Instance();
        }
    }
}
